<!--预警监测-->
<template>
    <div class="toggle_list">
        <div
            v-for="(item, index) in state.toggleList"
            :key="index"
            :class="toggleValueTab == index ? 'isacive' : ''"
            @click="toggleValue(index)"
        >
            {{ item.name }}
        </div>
    </div>
    <component :is="componentItem"></component>
</template>

<script setup lang="ts">
    import  { reactive, ref } from 'vue';
    import type { Component } from 'vue';
    import CustomEmergencySiderRightComponentWarningstatistics from './component/warningstatistics.vue'
    import CustomEmergencySiderRightComponentHandle from './component/handle.vue'
    //控制component的显示
    const componentItem = ref<Component>(CustomEmergencySiderRightComponentHandle);
    //控制按钮高亮
    const toggleValueTab =ref(0)
    //切换组件事件
    const toggleValue =(index:any) =>{
        toggleValueTab.value = index
        if(index === 0){
            componentItem.value = CustomEmergencySiderRightComponentHandle
        } else {
            componentItem.value = CustomEmergencySiderRightComponentWarningstatistics
        }
        
    }

    const state = reactive({
        toggleList: [
            {
                name: '预警事件'
            },
            {
                name: '预警统计'
            }
        ]
    });

</script>

<style scoped lang="scss">

.toggle_list {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 14px;
    margin-bottom: 10px;
    > div {
        width: 86px;
        height: 24px;
        text-align: center;
        line-height: 20px;
        font-size: 12px;
        color: #ffffff;
        background: rgba(27, 147, 251, 0.2);
        margin-right: 8px;
        &:last-child {
            margin-right: 0;
        }
    }
    .isacive {
        background: #1b93fb;
    }
}

</style>